<template>
  <!--闭合审核-->
  <div>
    <mu-expansion-panel  v-if="problemCloseApprovalVo" class="noshadow" :expand="true" >
      <div slot="header" class="noshadow_tit">
        <div><span class="noshadow_tit_con">复查人：</span><span class="noshadow_tit_name">{{problemCloseApprovalVo.reviewUserName}}</span></div>
        <div><span class="noshadow_tit_con">复查时间：</span><span class="noshadow_tit_name">{{ problemCloseApprovalVo.reviewTime || '---'}}</span>
        </div>
      </div>
      <section class="box">
         <p class="line-list textdot">
          复查结果：<span class="line-list-con">不合格</span>
        </p>
        <p class="line-list textdot">
          复查结果描述：<span class="line-list-con">{{ problemCloseApprovalVo.reviewDesc}}</span>
        </p>
        <section class="line-list img-box">
          现场照片：
          <div class="img-con">
            <img class="img" :preview="index" v-for="(i,index) in handurl(problemCloseApprovalVo.scenePhotos || null) " :key="index" :src="i"/>
          </div>
        </section>
        <section class="line-list img-box ">
            复查人签名：
            <div class="img-con" v-if="problemCloseApprovalVo.problemCloseVo && problemCloseApprovalVo.problemCloseVo.reviewSignature">
              <img preview="0" class="img" :src="problemCloseApprovalVo.problemCloseVo && problemCloseApprovalVo.problemCloseVo.reviewSignature" alt="">
            </div>
            <span v-else>暂无签名</span>
        </section>
        <p class="line-list textdot">
          申请问题闭合：<span class="line-list-con">是</span>
        </p>
        <p class="line-list textdot">
          申请时间：<span class="line-list-con">{{ problemCloseApprovalVo.problemCloseVo && problemCloseApprovalVo.problemCloseVo.applyTime}}</span>
        </p>
        <p class="line-list textdot">
          申请人：<span class="line-list-con">{{ problemCloseApprovalVo.problemCloseVo && problemCloseApprovalVo.problemCloseVo.applyUserName}}</span>
        </p>
        <p class="line-list textdot">
          备注：<span class="line-list-con">{{ problemCloseApprovalVo.problemCloseVo && problemCloseApprovalVo.problemCloseVo.reviewPcRemark}}</span>
        </p>
      </section>
    </mu-expansion-panel>
  </div>

</template>

<script>
import { MessageBox } from "mint-ui";
import Preview from './../preview/ImgPreview'
export default {
    name: "closedAudit",
    components:{
      Preview
    },
    props:{
      problemCloseApprovalVo:{
        type:Object,
        default: function () {
          return ""
        }
      },
      reviewId:{
        type:String,
        default: function () {
          return ""
        }
      }
    },
     data () {
      return{
        // 图片预览
        imgPreview: {
          open: false,
          imgUrl: ''
        },
      }
     },
     methods: {
       open(){
          this.imgPreview.imgUrl = props.url
          this.imgPreview.open = true
       },
        handurl(str) {
        if (!str) {
          return []
        } else {
          return str.split(',')
        }
      },
       //同意拒绝
      agrreOrNO(item,flag){
        let _this = this;
        MessageBox({
          title: '审批提示',
          message: `确认${flag==1?'拒绝':'同意'}此任务？`,
          confirmButtonText: '确认',
          showCancelButton:true,

        }).then(action => {
          console.log(action)
          if(action == 'confirm'){
            _this.postApproval(item, flag)
          }
        });
      },
      postApproval(list, flag){
        let obj = {
          id:this.$route.query.id,
          businessId: this.problemCloseApprovalVo.reviewId,
          applyType: '1',//0延期，1问题闭合
          flag: flag,
          endTime:new Date(new Date().getTime()+8*60*60*1000).toISOString().replace('T',' ').substr(0,19)
        }
        this.$openLoading();
        this.$A.Go('post','/safety/approval/submit',obj).then(success=>{
            if(success.code == 200){
              this.$A.MS('审批成功')
              // this.$emit('refresh')
              this.$router.back()
            } else {
              this.$A.MS(success.msg)
            }
            this.$closeLoading();
          },
          function(err) {
            console.warn(err);
          }
        );
      }
    }
  }
</script>

<style scoped lang="scss">
  @import "assign.scss";
</style>
